#region

using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

#endregion

namespace CuongHanh.Models
{
    [Table("tbl_ParentMaterial")]
    public class ParentMaterial : BaseClass2
    {
        [Key]
        [Column(Order = 0)]
        public int ChildStyleId { get; set; }

        /// <summary>
        ///     ChildStyleId
        /// </summary>
        public override int Key1
        {
            get
            {
                return ChildStyleId;
            }
        }

        [Key]
        [Column(Order = 1)]
        public int ParentStyleId { get; set; }

        /// <summary>
        ///     ParentStyleId
        /// </summary>
        public override int Key2
        {
            get
            {
                return ParentStyleId;
            }
        }

        [Key]
        [Column(Order = 2)]
        public int ParentMaterialId { get; set; }

        /// <summary>
        ///     ParentMaterialId
        /// </summary>
        public override int Key3
        {
            get
            {
                return ParentMaterialId;
            }
        }

        public double Price { get; set; }

        public double PriceOfDifferentSize { get; set; }

        public string Image { get; set; }

        #region Function

        public ParentMaterial()
        {
        }

        public ParentMaterial(ParentMaterial model)
        {
            ParentStyleId = model.ParentStyleId;
            ParentMaterialId = model.ParentMaterialId;
            ChildStyleId = model.ChildStyleId;
            Price = model.Price;
            Image = model.Image;
        }

        public void UpdateInfo(ParentMaterial model)
        {
            ParentStyleId = model.ParentStyleId;
            ParentMaterialId = model.ParentMaterialId;
            ChildStyleId = model.ChildStyleId;
            Price = model.Price;
            PriceOfDifferentSize = model.PriceOfDifferentSize;
            if(!string.IsNullOrWhiteSpace(model.Image))
                Image = model.Image;
        }

        #endregion
    }
}
